/*
函数重载
* */

//参数重载
function sum(a: number, b: string);
function sum(a: string, b: number);
function sum(a: any, b: any) {
  return a + b
}

// react createElement
/*
export function createElement (
  context: Component,
  tag: any,
  data: any,
  children: any,
  normalizationType: any,
  alwaysNormalize: boolean
): VNode | Array<VNode> {
  if (Array.isArray(data) || isPrimitive(data)) {
    normalizationType = children
    children = data
    data = undefined
  }
  if (isTrue(alwaysNormalize)) {
    normalizationType = ALWAYS_NORMALIZE
  }
  return _createElement(context, tag, data, children, normalizationType)
}*/


// vue createElement
/*
const childrenLength = arguments.length - 2;
if (childrenLength === 1) {
  props.children = children;
} else if (childrenLength > 1) {
  const childArray = Array(childrenLength);
  for (let i = 0; i < childrenLength; i++) {
    childArray[i] = arguments[i + 2];
  }
  if (__DEV__) {
    if (Object.freeze) {
      Object.freeze(childArray);
    }
  }
  props.children = childArray;
}
*/

// buffer
/*Buffer.prototype.slice = function slice(start, end) {
  const srcLength = this.length
  end = end !== undefined ? srcLength: srcLength
  const newLength = end > start ? end - start : 0
  return new FastBuffer(this.buffer, this.byteOffset + start, newLength)
}*/


// createStore
export default function createStore(reducer, preloadedState, enhancer) {
  if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
    enhancer = preloadedState
    preloadedState = undefined
  }

  // ↓ store = applyMiddleware(logger)(createStore)(reducer, initialState)
  if (typeof enhancer !== 'undefined'){
    return enhancer(createStore)(reducer, preloadedState)
  }
}


//axios
function getDefaultAdapter() {
  let adapter
  if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
    adapter = require('./adapters/http')
  } else if (typeof XMLHttpRequest !== 'undefined') {
    adapter = require('./adapters/xhr')
  }
  return adapter
}

// polyfill
// polyfill可以让我们处理浏览器兼容和屏蔽了浏览器差异
// removeEvent
/*
jQuery.removeEvent = document.removeEventListener ?
  function( elem, type, handle ) {
    if ( elem.removeEventListener ) {
      elem.removeEventListener( type, handle, false )
    }
  } :
  function( elem, type, handle ) {
    if ( elem.detachEvent ) {
      elem.detachEvent( 'on' + type, handle )
    }
  }*/
